﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/UserTemplate.master" AutoEventWireup="true"
    CodeBehind="Order.aspx.cs" Inherits="TeamBuy.AccessWebUI.Account.Order" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphUserHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphUser" runat="server">
    <div id="bdw" class="bdw">
        <div id="bd" class="cf">
            <div id="coupons">
                <div id="content" class="coupons-box">
                    <div class="dashboard" id="dashboard">
                        <ul>
                            <li><a href="Coupon.aspx">我的美团券</a><span></span></li>
                            <li class="current"><a href="Order.aspx">我的订单</a><span></span></li>
                            <li><a href="MyInvites.aspx">我的邀请</a><span></span></li>
                            <li><a href="Point.aspx">我的积分</a><span></span></li>
                            <li><a href="Credit.aspx">账户余额</a><span></span></li>
                            <li><a href="Setting.aspx">账户设置</a><span></span></li>
                        </ul>
                    </div>
                    <div class="box clear">
                        <div class="box-top">
                        </div>
                        <div class="box-content">
                            <div class="head">
                                <h2>
                                    我的订单</h2>
                                <ul class="filter">
                                    <li class="label">分类: </li>
                                    <li <asp:Literal ID="ltlAllStyle" Text="class='current'" runat="server"></asp:Literal>><asp:LinkButton 
                                            ID="lbtnAll" runat="server" onclick="lbtnAll_Click">全部</asp:LinkButton></li>
                                    <li <asp:Literal ID="ltlNotPaiedStyle" runat="server"></asp:Literal>><asp:LinkButton 
                                            ID="lbtnNotPaied" runat="server" onclick="lbtnNotPaied_Click">未付款</asp:LinkButton></li>
                                    <li <asp:Literal ID="ltlPaiedStyle" runat="server"></asp:Literal>><asp:LinkButton 
                                            ID="lbtnPaied" runat="server" onclick="lbtnPaied_Click">已付款</asp:LinkButton></li>
                                </ul>
                            </div>
                            <div class="sect">
                                <table id="Table1" cellspacing="0" cellpadding="0" border="0" class="coupons-table">
                                    <tbody>
                                        <tr>
                                            <th width="auto">
                                                团购项目
                                            </th>
                                            <th width="30">
                                                数量
                                            </th>
                                            <th width="80">
                                                总价
                                            </th>
                                            <th width="80">
                                                订单状态
                                            </th>
                                            <th width="80">
                                                操作
                                            </th>
                                        </tr>
                                        <asp:ListView ID="lvOrder" runat="server" DataSourceID="adsOrder" 
                                            ondatabound="lvOrder_DataBound">
                                            <ItemTemplate>
                                                <%#(Convert.ToInt32(Eval("OrderStatus")) == 0) ? 
                                                    ((new TeamBuy.AccessService.TeamBuyDealService().GetLeftDealNumber(Convert.ToInt32(Eval("DealID")))) >= Convert.ToInt32(Eval("Quantity")) ? 
                                                                                                    SetStatus(Convert.ToInt32(Eval("OrderID")), Convert.ToInt32(Eval("OrderStatus")), 3, "") :
                                                                                                                                                        (Eval("DateFinished") == DBNull.Value ? "" : Convert.ToDateTime(Eval("DateFinished")) <= DateTime.Now ? SetStatus(Convert.ToInt32(Eval("OrderID")), Convert.ToInt32(Eval("OrderStatus")), 4, "") : "")) : "" %>
                                                <tr class="alt">
                                                    <td width="auto" class="deal">
                                                        <table class="deal-info">
                                                            <tbody>
                                                                <tr>
                                                                    <td class="pic">
                                                                        <a href='/Deal.aspx?ID=<%#TeamBuy.Common.PublicFunction.DESEncrypt(Eval("DealID").ToString()) %>' target="_blank" title='<%#Eval("DealTitle") %>'><img src='<%#Eval("MainImage") %>' width="75" height="46" /></a>
                                                                    </td>
                                                                    <td class="text">
                                                                        <a class="deal-title" href='/Deal.aspx?ID=<%#TeamBuy.Common.PublicFunction.DESEncrypt(Eval("DealID").ToString()) %>' title='<%#Eval("DealTitle") %>' target="_blank"><%#Eval("ProductName") %></a>
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </td>
                                                    <td width="30">
                                                        <%#Eval("Quantity") %>
                                                    </td>
                                                    <td width="80">
                                                        <span class="money">¥</span><%#Eval("TotalPrice") %></td>
                                                    <td width="80">
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 0 ? "<span class=\"unpay\">未付款</span>" : "" %>
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 3 || Convert.ToInt32(Eval("OrderStatus")) == 4 ? "<span class=\"fade\">已结束<br>未付款</span>" : ""%>
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 1 || Convert.ToInt32(Eval("OrderStatus")) == 2 ? "<span class=\"fade\">已付款</span>" : ""%>
                                                    </td>
                                                    <td width="80" class="op">
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 0 ? "<a href=\"OrderPay.aspx?Order=" + TeamBuy.Common.PublicFunction.DESEncrypt(Eval("OrderID").ToString()) + "\">付款</a> <a class=\"order-cancel\" href=\"\">取消</a>" : "" %>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                            <AlternatingItemTemplate>
                                                <%#(Convert.ToInt32(Eval("OrderStatus")) == 0) ? 
                                                    ((new TeamBuy.AccessService.TeamBuyDealService().GetLeftDealNumber(Convert.ToInt32(Eval("DealID")))) >= Convert.ToInt32(Eval("Quantity")) ? 
                                                                                                    SetStatus(Convert.ToInt32(Eval("OrderID")), Convert.ToInt32(Eval("OrderStatus")), 3, "") :
                                                                                                                                                        (Eval("DateFinished") == DBNull.Value ? "" : Convert.ToDateTime(Eval("DateFinished")) <= DateTime.Now ? SetStatus(Convert.ToInt32(Eval("OrderID")), Convert.ToInt32(Eval("OrderStatus")), 4, "") : "")) : "" %>
                                                <tr>
                                                    <td width="auto" class="deal">
                                                        <table class="deal-info">
                                                            <tbody>
                                                                <tr>
                                                                    <td class="pic">
                                                                        <a href='/Deal.aspx?ID=<%#TeamBuy.Common.PublicFunction.DESEncrypt(Eval("DealID").ToString()) %>' target="_blank" title='<%#Eval("DealTitle") %>'><img src='<%#Eval("MainImage") %>' width="75" height="46" /></a>
                                                                    </td>
                                                                    <td class="text">
                                                                        <a class="deal-title" href='/Deal.aspx?ID=<%#TeamBuy.Common.PublicFunction.DESEncrypt(Eval("DealID").ToString()) %>' title='<%#Eval("DealTitle") %>' target="_blank"><%#Eval("ProductName") %></a>
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </td>
                                                    <td width="30">
                                                        <%#Eval("Quantity") %>
                                                    </td>
                                                    <td width="80">
                                                        <span class="money">¥</span><%#Eval("TotalPrice") %></td>
                                                    <td width="80">
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 0 ? "<span class=\"unpay\">未付款</span>" : "" %>
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 3 || Convert.ToInt32(Eval("OrderStatus")) == 4 ? "<span class=\"fade\">已结束<br>未付款</span>" : ""%>
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 1 || Convert.ToInt32(Eval("OrderStatus")) == 2 ? "<span class=\"fade\">已付款</span>" : ""%>
                                                    </td>
                                                    <td width="80" class="op">
                                                        <%#Convert.ToInt32(Eval("OrderStatus")) == 0 ? "<a href=\"OrderPay.aspx?Order=" + TeamBuy.Common.PublicFunction.DESEncrypt(Eval("OrderID").ToString()) + "\">付款</a> <a class=\"order-cancel\" href=\"\">取消</a>" : ""%>
                                                    </td>
                                                </tr>
                                            </AlternatingItemTemplate>
                                            <LayoutTemplate>
                                                <div id="itemPlaceholderContainer" runat="server" style="">
                                                    <span id="itemPlaceholder" runat="server" />
                                                </div>
                                                <div style="">
                                                </div>
                                            </LayoutTemplate>
                                        </asp:ListView>
                                    </tbody>
                                </table>
                                <asp:AccessDataSource ID="adsOrder" runat="server" DataFile="~/App_Data/TeamBuyData.mdb"
                                    
                                    SelectCommand="SELECT * FROM [vw_OrderInfo] WHERE ([UserID] = ?) ORDER BY [OrderID] DESC">
                                    <SelectParameters>
                                        <asp:SessionParameter DefaultValue="0" Name="UserID" SessionField="UserID" 
                                            Type="Int32" />
                                    </SelectParameters>
                                </asp:AccessDataSource>
                                <div class="clear">
                                </div>
                                <div class="paginator">
                                    <asp:DataPager ID="dpOrder" runat="server" PagedControlID="lvOrder" PageSize="20">
                                        <Fields>
                                            <asp:NextPreviousPagerField ShowFirstPageButton="True" ButtonCssClass="paginator_li paginator_li_a"
                                                ShowLastPageButton="false" ShowNextPageButton="False" FirstPageText="首页" NextPageText="下一页"
                                                PreviousPageText="上一页" />
                                            <asp:NumericPagerField CurrentPageLabelCssClass="paginator_li_current" NumericButtonCssClass="paginator_li paginator_li_a"
                                                ButtonCount="10" />
                                            <asp:NextPreviousPagerField ShowLastPageButton="false" ButtonCssClass="paginator_li paginator_li_a"
                                                ShowPreviousPageButton="False" NextPageText="下一页" PreviousPageText="上一页" />
                                        </Fields>
                                    </asp:DataPager>
                                </div>
                            </div>
                        </div>
                        <div class="box-bottom">
                        </div>
                    </div>
                </div>
                <div id="sidebar">
                    <div class="sbox side-help">
                        <div class="sbox">
                            <div class="sbox-top">
                            </div>
                            <div class="sbox-content">
                                <div class="side-tip">
                                    <h3 class="first">
                                        我已支付成功，为什么没有美团券？</h3>
                                    <p>
                                        因为还没有到达最低团购人数，一旦凑够人数，您就会看到美团券了。</p>
                                    <h3>
                                        什么是已过期订单？</h3>
                                    <p>
                                        如果某个订单未及时付款，那么等团购结束时就无法再付款了，这种订单就是过期订单。</p>
                                    <h3>
                                        哪种订单可以评价？</h3>
                                    <p>
                                        只有已消费过的订单才可以评价，参与评价可以获得积分奖励！</p>
                                </div>
                            </div>
                            <div class="sbox-bottom">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- bd end -->
        </div>
    </div>
</asp:Content>
